package com.main.common.base.base.impl;

import com.main.common.base.base.dto.BaseAddDTO;
import com.main.common.base.base.BaseAssembler;
import com.main.common.base.base.entity.BaseEntity;
import com.main.common.utils.ZoneDateTimeConvert;
import org.springframework.stereotype.Service;

@Service
public class BaseAddAssemblerImpl<E extends BaseEntity,D extends BaseAddDTO> implements BaseAssembler<E,D> {

    private final ZoneDateTimeConvert zoneDateTimeConvert = new ZoneDateTimeConvert();

    @Override
    public D toDTO(E entity, D dto) {
        dto.setRemark(entity.getRemark());
        return dto;
    }

    @Override
    public  E toEntity(D dto, E entity) {
        entity.setCreatedBy(Long.valueOf("1872535844899921921"));
        entity.setCreatedAt(zoneDateTimeConvert.localToSystem());
        entity.setRemark(dto.getRemark());
        return entity;
    }

}
